package threadpool;

import thread.ThreadUtils;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

public class ThreadPoolSubmitRunnableDemo {

    public static void main(String[] args) throws Exception {
        ExecutorService threadPool = Executors.newFixedThreadPool(5);
        Future<?> runnable = threadPool.submit(new Runnable() {
            @Override
            public void run() {
                ThreadUtils.sleep(100);
                System.out.println("当前线程：" + Thread.currentThread().getName());
            }
        });
        Object result = runnable.get(); //result为null
        System.out.println(result.toString()); //NPE导致无法执行下一步
        threadPool.shutdown();
    }
}
